/**
 * 
 */
package com.ginger.rabbitmq.stream;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Service;

import com.rabbitmq.client.Channel;

/**
 * @Description: RabbitMQ发送
 * @author 姜锋
 * @date 2019年4月2日 下午10:05:36 
 * @version V1.0   
 *
 */
@EnableBinding(Barista.class)
@Service
public class RabbitmqReceive {
	
	private final static Logger logger = LoggerFactory.getLogger(RabbitmqReceive.class);
	
	
	@SuppressWarnings("rawtypes")
	@StreamListener(Barista.INPUT_CHANNEL)
	public void receiveMessage (Message message) throws Exception{
		
		Channel Channel = (Channel) message.getHeaders().get(AmqpHeaders.CHANNEL);
		Long deliveryTag = (Long)message.getHeaders().get(AmqpHeaders.DELIVERY_TAG);
		logger.warn("接受的数据"+message);
		logger.warn("接受的数据内容"+message.getPayload());
		Channel.basicAck(deliveryTag, false);
	}
}
